<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Tab 切换 - 锚点</title>
</head>

<body>
    <!--
        https://blog.csdn.net/jvid_sky/article/details/53260616

        原理:通过a标签的锚点实现切换，也就a的href的路径是要切换div的id

1.创建一个类名为wrap的div作为容器

2.创建一个类名为nav的div，在里边创建四个a标签，a标签的href分别是要切换到的div的id

3.创建一个和nav兄弟关系的类名为sh的容器用来放置切换的div

4.创建显示内容div，id分别和上面a标签对应
————————————————
版权声明：本文为CSDN博主「遨游苍穹_」的原创文章，遵循CC 4.0 BY-SA版权协议，转载请附上原文出处链接及本声明。
原文链接：https://blog.csdn.net/jvid_sky/article/details/53260616
    -->
    <div class="wrap">
        <div class="nav">
            <a href="#home">home</a>
            <a href="#list">list</a>
            <a href="#news">news</a>
            <a href="#mine">mine</a>
        </div>
        <div class="sh">
            <div id="home">home-page</div>
            <div id="list">list-page</div>
            <div id="news">news-page</div>
            <div id="mine">mine-page</div>
        </div>
    </div>
    <!--
        css样式设置
将类名为sh下的div设置为display：none；然后通过div:target{display:block}实现显示选中项
    -->
    <style type="text/css">
        * {
            margin: 0;
            padding: 0
        }

        .wrap {
            width: 400px;
            height: 600px;
            border: 1px solid brown;
            margin: 20px auto;
            position: relative;
        }

        .nav {
            width: 100%;
            height: 30px;
        }

        .nav a {
            width: 99px;
            height: 30px;
            text-align: center;
            line-height: 30px;
            border-right: 1px solid brown;
            border-bottom: 1px solid brown;
            float: left;
            text-decoration: none;
            color: black;
        }

        .sh {
            width: 400px;
            height: 569px;
            position: absolute;
            left: 0;
            top: 31px;
            background: #eeeeee;
        }

        .sh div {
            display: none;
            text-align: center;
        }

        .sh div:target {
            display: block;
        }
    </style>
</body>

</html>